import { defineStore } from 'pinia';
import { ref } from 'vue'

export const useUserStore = defineStore('token', () => {
    //定义状态内容
    
    const token = ref('');
    //定义函数修改token的值
    const setToken = (newToken) => {
        token.value = newToken;
    }

    const getToken = () => {
       return token.value 
  }

    //移除token
    const removeToken = () => {
        token.value = '';
    }

    return { token, setToken, removeToken,getToken }
}, {
  persist: true//持久化存储
});